<?php
		require('config.php');
		$user_id=$_REQUEST['user_id'];
		$address_id=$_REQUEST['address_id'];
		//$user_id=1;
		$sql="DELETE from `".$oto."_user_address` where `userId`='".$user_id."' and addressId='{$address_id}'";
		$result2=$db->query($sql);
		if($result2)
		{
			$sql="select * from `".$oto."_user_address` where `userId`='".$user_id."'";
			$result=$db->query($sql);
			while($row=$result->fetch_assoc()){
				$user_address[]=$row;//将取得的所有数据赋值给person_info数组
			}
			if(!isset($user_address))
			{

			}
			else
			{
				$sql="select * from `".$oto."_user_address` where `userId`='".$user_id."' and isDefault='1'";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$user_address2[]=$row;//将取得的所有数据赋值给person_info数组
				}
				if(!isset($user_address2))
				{
					$lin_id=$user_address[0]['addressId'];
					$sql="update ".$oto."_user_address set isDefault='1' where userId='{$user_id}' and addressId='{$lin_id}'";
					$result=$db->query($sql);
				}
			}
		}
		else
		{

		}
		echo json_encode($result2);
?>